package com.web;

import com.pojo.List_db;
import com.service.ListService_db;
import com.util.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/list")
public class ListController_db {
    @Autowired
    private ListService_db listServiceDb;

    @RequestMapping("/show")
    public ResultEntity list(String name,Integer id){
        return ResultEntity.ok(listServiceDb.list(name,id));
    }

    @RequestMapping("/all")
    public ResultEntity listAll(){
        return ResultEntity.ok(listServiceDb.listAll());
    }

    @RequestMapping("/listid")
    public ResultEntity listById(Integer id){
        return ResultEntity.ok(listServiceDb.listById(id));
    }

    @RequestMapping("/add")
    public ResultEntity add(List_db listDb){
        return ResultEntity.ok(listServiceDb.add(listDb));
    }

    @RequestMapping("/update")
    public ResultEntity update(List_db listDb){
        return ResultEntity.ok(listServiceDb.update(listDb));
    }

    @RequestMapping("/delete")
    public ResultEntity del(Integer bId){
        return ResultEntity.ok(listServiceDb.del(bId));
    }
}
